<style>
span{float:left;}
#content-right{
	margin:0 auto;
	float:none;
	width:800px;
}
.button1{
	float:left;
	clear:both;
	background: url("<?php echo base_url()?>resources/images/add.png") no-repeat scroll 0 0 transparent;
	width:200px;cursor:pointer;
}
#content-right,#info{clear:both;float:left;margin-left:113px;}
#add_new{background: url("<?php echo base_url()?>resources/images/btnAdd.png") no-repeat scroll 0 0 transparent;width:135px;height:30px;padding-top:20px;padding-left:15px;margin-bottom:5px;}

table.tbContentLeft{margin:0px;}
#chitiet2{
	width:225px;
	float:right;
	border-radius: 10px;
	background-color:#fff;
	border:5px solid #CCCCCC;
	padding:10px;
	margin-left:5px;
	margin-left:65px;
	margin-right: 110px;
}
#chitiet2 h3{margin-bottom:5px;}
#chitiet2 .first{ text-align: left;
    width: 82px;float:left;}
#chitiet2 input{float:left;}

#chitiet2 input{background-color: #DDDDDD;
    padding: 5px;
   line-height: 1;
   border: 0;
   border-radius: 1px;
   height: 18px;}
#chitiet2 textarea{padding: 5px;
   line-height: 1;
   border: 0;
   border-radius: 1px;
	resize:none;background-color: #DDDDDD;border:0;width: 195px;}
</style>
<script type="text/javascript">
var auto = false;
 $(function() {
 
	 // run the currently selected effect
	function runEffect(rel) {
		// get effect type from
		// var selectedEffect = $( "#effectTypes" ).val();
		var selectedEffect = 'blind';
		// most effect types need no options passed by default
		var options = {};
		// some effects have required parameters
		if ( selectedEffect === "scale" ) {
		options = { percent: 0 };
		} else if ( selectedEffect === "size" ) {
		options = { to: { width: 200, height: 60 } };
		}
		// run the effect
		$( "#"+rel ).toggle( selectedEffect, options, 500 );
	};
	// set effect from select menu value
	
	$(".edit").focusout(function(){
		if($(this).attr("rel")!="auto" || auto){
			var answer = confirm("Co' muon sua ko?");
			var value = $(this).val();
			var id_change = "pibien"+$(this).attr('id');
			var rel = $(this).attr("rel");
			if($(this).attr("rel")=="auto" ){
				var tam = $(this).attr("id").replace("auto","");
				rel = $("#"+tam).attr("rel")+",0,"+ $(this).val();
				value = $("#"+tam).val();
				id_change = "pibien" + tam;
			}
			if (answer){
				$.ajax({
					type: 'post',
					url: '<?php echo base_url()?>transaction/updateItem',
					data: {
						id_change:id_change,
						value:value,
						rel:rel
						},
					success: function(data){
							 var R = eval('(' + data + ')'); 
							 if(R.result){
								$("#"+R.id_change).html(R.value);
								$("#"+R.id_change.replace("pibien","")).hide("slow");
								$("#auto"+R.id_change.replace("pibien","")).hide("slow");
								$("#"+R.id_change).show("slow");
							}
							auto = false;
					},
					statusCode:{
						404: function(){
							
						}
					}
				});
			}else{
				$(this).hide("slow");
				$("#pibien"+$(this).attr("id")).show("slow");
				$("#pibien"+$(this).attr("id").replace("auto","")).show("slow");
				auto = false;
			}
		}else{
			auto = true;
		}
	});
	$(".doubleclick").dblclick(function(){
		$("#"+$(this).attr("rel")).show("slow");
		$("#auto"+$(this).attr("rel")).show("slow");
		var t = $("#"+$(this).attr("rel"));
		var v = t.val();
        t.focus().val("").val(v).select();
		t = $("#auto"+$(this).attr("rel"));
		v = t.val();
        t.focus().val("").val(v).select();
		$(this).hide("slow");
	});
	
 });
 function delItem(pathurl){
	$.ajax({
					type: 'post',
					url: pathurl,
					data: {
						id_change:id_change,
						value:value,
						rel:rel
						},
					success: function(data){
							 var R = eval('(' + data + ')'); 
							 if(R.result){
							}
					},
					statusCode:{
						404: function(){
							
						}
					}
	});
 }
 </script>
<!--
<?php $duynhat =  uniqid();?>
	<span rel="<?php echo $duynhat;?>" id="pibien<?php echo $duynhat;?>" class="doubleclick">800.000vnd</span>
	<input id="<?php echo $duynhat;?>" class="edit" value="800" style="display:none;" rel="transaction,Tran_ID,18,Money" />
-->
		<h1>Thanh toan</h1>
<?php echo form_open(current_url(),"style='display:none;'"); ?>	
	Chọn: <input id="transaction_dt" type="text" name="transaction_dt" value="<?php echo $time;?>"  />
	<input type="submit" value="Liệt kê" />
	<?php echo form_close(); ?>
<div id="content-right" class="type1">
	
			<table border="0">
			   <tr border="0">
				   <?php
                foreach( $rules as $i ){
                    if( in_array( $i[ 'field_id' ], $master_limited  ) ){
						if(isset($i[ 'width' ]))
							$width = "width = '".$i[ 'width' ]."'";
						else
							$width = "";
                        echo "<th $width class='".$i['class']."' style='".$i['style']."'>". $i[ 'label' ]."</th>";
					}
                }
				
            ?>
			 <th width="9%" class="last">Chức năng</th>
			   <?php
                for( $i = 0; $i < count( $results ); $i++ ){
                    echo "<tr>";
					if($i%2==1) $odd="odd"; else $odd="";
                            foreach( $rules as $item ){
                           	    if( $item[ 'field_id' ] != "Image_ID" && in_array( $item[ 'field_id' ], $master_limited ) ){ 	
         			                echo "<td class='$odd'>";
									if($item[ 'control' ] == "time")
										echo date("d/m/y",$results[ $i ][ $item[ 'field_id' ] ]);
									else if($item[ 'control' ] == "vnd") 
										echo formatcurrency($results[ $i ][ $item[ 'field_id' ] ] * 1000);
									else if($item[ 'control' ] == "percent") 
										echo $results[ $i ][ $item[ 'field_id' ] ]."%";
									else echo $results[ $i ][ $item[ 'field_id' ] ];
            						echo "</td>";					
								}
                            }
							echo "<td class='$odd l'>".$results[ $i ]['Edit']."</td>";
                    echo "</tr>";
                }
            ?>
			<tr><td colspan="<?php echo count($rules);?>"><center><div class="pagination"><?php echo $this->pagination->create_links(); ?></div></center></td></tr>
			</table>
</div> <!-- content right -->
<div id="chitiet2">
	<h3>Tips trong ngay</h3>
	<?php foreach($tientips as $item){?>
	<div class="both" style="float: left;margin-top:3px;">
		<span class="first"><?php echo $item['Name']?></span><input disabled value="<?php echo formatcurrency($item['Price']*1000)?>" size="20" />	
	</div>
	<?php }?>
	<div class="both" style="float: left;margin-top:5px;">
		<span class="first">Tong cong</span> <span> <?php echo formatcurrency($sum_tientip*1000);?></span>
	</div>
	<div class="both"></div>
</div><!-- end chitiet2 -->
		<div class="both"></div>
</div>